﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace game
{
    [StructLayout(LayoutKind.Sequential)]
    public struct PointSpriteParticleVertex
    {
        public Vector3 InitialPosition;
        public Vector3 InitialVelocity;
        public float InitialSize; // In pixels.
        public float InitialTimeMs;
        public float DieLifeTimeMs;
        // float mass;
        public Color InitialColor;

        public static VertexElement[] VertexElements;
        public static VertexDeclaration VertexDecl;
        public static int SizeInBytes { get; private set; }

        static PointSpriteParticleVertex()
        {
            VertexElements = new VertexElement[] { // must have the same format as Particle struct
                    new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
                    new VertexElement(0, 12, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
                    new VertexElement(0, 24, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),
                    new VertexElement(0, 28, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 2),
                    new VertexElement(0, 32, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 3),
                    new VertexElement(0, 36, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0) 
                };

            VertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice, VertexElements);

            SizeInBytes = 12 + 12 + 4 + 4 + 4 + 4;
        }
    }
}
